home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209s.zip / octave-2.09 / src / pt-pr-code.h < prev    next >
C/C++ Source or Header  |  1997-03-07  |  4KB  |  185 lines

  1. /*
  2.  
  3. Copyright (C) 1996 John W. Eaton
  4.  
  5. This file is part of Octave.
  6.  
  7. Octave is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2, or (at your option) any
  10. later version.
  11.  
  12. Octave is distributed in the hope that it will be useful, but WITHOUT
  13. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15. for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with Octave; see the file COPYING.  If not, write to the Free
  19. Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  20.  
  21. */
  22.  
  23. #if !defined (octave_tree_print_code_h)
  24. #define octave_tree_print_code_h 1
  25.  
  26. #if defined (__GNUG__)
  27. #pragma interface
  28. #endif
  29.  
  30. #include <string>
  31.  
  32. #include "pt-walk.h"
  33.  
  34. // How to print the code that the parse trees represent.
  35.  
  36. class
  37. tree_print_code : public tree_walker
  38. {
  39. public:
  40.  
  41.   tree_print_code (ostream& os_arg, const string& pfx = string (),
  42.            bool pr_orig_txt = true)
  43.     : os (os_arg), prefix (pfx), print_original_text (pr_orig_txt) { }
  44.  
  45.   ~tree_print_code (void) { }
  46.  
  47.   void visit_argument_list (tree_argument_list&);
  48.  
  49.   void visit_binary_expression (tree_binary_expression&);
  50.  
  51.   void visit_break_command (tree_break_command&);
  52.  
  53.   void visit_builtin (tree_builtin&);
  54.  
  55.   void visit_colon_expression (tree_colon_expression&);
  56.  
  57.   void visit_continue_command (tree_continue_command&);
  58.  
  59.   void visit_for_command (tree_for_command&);
  60.  
  61.   void visit_function (tree_function&);
  62.  
  63.   void visit_function_header (tree_function&);
  64.  
  65.   void visit_function_trailer (tree_function&);
  66.  
  67.   void visit_global (tree_global&);
  68.  
  69.   void visit_global_command (tree_global_command&);
  70.  
  71.   void visit_global_init_list (tree_global_init_list&);
  72.  
  73.   void visit_identifier (tree_identifier&);
  74.  
  75.   void visit_if_clause (tree_if_clause&);
  76.  
  77.   void visit_if_command (tree_if_command&);
  78.  
  79.   void visit_if_command_list (tree_if_command_list&);
  80.  
  81.   void visit_switch_case (tree_switch_case&);
  82.  
  83.   void visit_switch_case_list (tree_switch_case_list&);
  84.  
  85.   void visit_switch_command (tree_switch_command&);
  86.  
  87.   void visit_index_expression (tree_index_expression&);
  88.  
  89.   void visit_indirect_ref (tree_indirect_ref&);
  90.  
  91.   void visit_matrix (tree_matrix&);
  92.  
  93.   void visit_matrix_row (tree_matrix_row&);
  94.  
  95.   void visit_multi_assignment_expression (tree_multi_assignment_expression&);
  96.  
  97.   void visit_no_op_command (tree_no_op_command&);
  98.  
  99.   void visit_oct_obj (tree_oct_obj&);
  100.  
  101.   void visit_constant (tree_constant&);
  102.  
  103.   void visit_parameter_list (tree_parameter_list&);
  104.  
  105.   void visit_plot_command (tree_plot_command&);
  106.  
  107.   void visit_plot_limits (plot_limits&);
  108.  
  109.   void visit_plot_range (plot_range&);
  110.  
  111.   void visit_postfix_expression (tree_postfix_expression&);
  112.  
  113.   void visit_prefix_expression (tree_prefix_expression&);
  114.  
  115.   void visit_return_command (tree_return_command&);
  116.  
  117.   void visit_return_list (tree_return_list&);
  118.  
  119.   void visit_simple_assignment_expression (tree_simple_assignment_expression&);
  120.  
  121.   void visit_statement (tree_statement&);
  122.  
  123.   void visit_statement_list (tree_statement_list&);
  124.  
  125.   void visit_subplot (subplot&);
  126.  
  127.   void visit_subplot_list (subplot_list&);
  128.  
  129.   void visit_subplot_style (subplot_style&);
  130.  
  131.   void visit_subplot_using (subplot_using&);
  132.  
  133.   void visit_try_catch_command (tree_try_catch_command&);
  134.  
  135.   void visit_unary_expression (tree_unary_expression&);
  136.  
  137.   void visit_unwind_protect_command (tree_unwind_protect_command&);
  138.  
  139.   void visit_while_command (tree_while_command&);
  140.  
  141. private:
  142.  
  143.   ostream& os;
  144.  
  145.   string prefix;
  146.  
  147.   bool print_original_text;
  148.  
  149.   static int curr_print_indent_level;
  150.   static bool beginning_of_line;
  151.  
  152.   void reset_indent_level (void)
  153.     { curr_print_indent_level = 0; }
  154.  
  155.   void increment_indent_level (void)
  156.     { curr_print_indent_level += 2; }
  157.  
  158.   void decrement_indent_level (void)
  159.     { curr_print_indent_level -= 2; }
  160.  
  161.   void newline (void);
  162.  
  163.   void indent (void);
  164.  
  165.   void reset (void);
  166.  
  167.   // Must create with an output stream!
  168.  
  169.   tree_print_code (void);
  170.  
  171.   // No copying!
  172.  
  173.   tree_print_code (const tree_print_code&);
  174.  
  175.   tree_print_code& operator = (const tree_print_code&);
  176. };
  177.  
  178. #endif
  179.  
  180. /*
  181. ;;; Local Variables: ***
  182. ;;; mode: C++ ***
  183. ;;; End: ***
  184. */
  185.